/*
 * @FilePath: \undefinedc:\Users\sxjct\.leetcode\154.寻找旋转排序数组中的最小值-ii.cpp
 * @Brief: 
 * @Version: 1.0
 * @Date: 2021-04-08 20:58:11
 * @Author: tianyiyi
 * @Copyright: Copyright@tianyiyi
 * @LastEditors: Mr.Tian
 * @LastEditTime: 2021-04-08 21:09:28
 */
/*
 * @lc app=leetcode.cn id=154 lang=cpp
 *
 * [154] 寻找旋转排序数组中的最小值 II
 */

// @lc code=start
class Solution {
public:
    int findMin(vector<int>& nums) {
        quickSort(nums,0,nums.size() - 1);
        return nums[0];
    }

    void quickSort(vector<int> &nums, int left,int right)
    {
        if(left < right)
        {
            int low = left;
            int high = right;
            int pivot = nums[left];

            while(low < high)
            {
                while(low < high && nums[high] >= pivot)
                {
                    high--;
                }
                nums[low] = nums[high];
                while(low < high && nums[low] <= pivot)
                {
                    low++;
                }
                nums[high] = nums[low];
            }
            nums[low] = pivot;
            quickSort(nums,left,low - 1);
        }
    }

};
// @lc code=end

